#include <iostream>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
using namespace std;
#include <thread>

void doing()
{
    cout << "這是子線程的ID：" << this_thread::get_id() << endl;
    for (size_t i = 0; i < 10; i++)
    {
        this_thread::sleep_for(chrono::seconds(1));
        cout << "我是子線程 " << i << endl;
    }
}

int main(int argc, char **argv)
{

    cout << " 主線程開始了:" << this_thread::get_id() << endl;
    thread t(doing);
    for (size_t i = 0; i < 10; i++)
    {
        this_thread::sleep_for(chrono::seconds(1));
        cout << "我是父線程 " << i << endl;
    }
    t.join();

    return 0;
}